package com.ficus.road.maintain.core.model.zh.xlj;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ficus.road.maintain.core.model.xlj.Xlj;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * @author xiawen yang
 * @date 2022/6/27 上午11:19
 */
@Data
public class XljBasicInfoZH {

    private String unid;

    private String xljName;

    private String manageUnit;

    private String manageTel;

    private String maintain;

    private String waterUnit;

    private String waterTel;

    private String police;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date rcvTime;

    private String xljNature;

    private String uniIdHuwan;

    private String xljEastlngBd09;

    private String xljNorthlatBd09;

    private List<CameraZH> XLJ_CAM_INFO;

    public Xlj convert2Xlj(XljBasicInfoZH zh, Date date) {
        return Xlj.builder()
                .id(zh.getUnid())
                .uniIdHuwan(zh.getUniIdHuwan())
                .xljName(zh.getXljName())
                .manageUnit(zh.getManageUnit())
                .manageTel(zh.getManageTel())
                .maintain(zh.getMaintain())
                .waterUnit(zh.getWaterUnit())
                .waterTel(zh.getWaterTel())
                .police(zh.getPolice())
                .rcvTime(zh.getRcvTime())
//                .xljNature(zh.getXljNature())
                .longitude(zh.getXljEastlngBd09())
                .latitude(zh.getXljNorthlatBd09())
                .syncTime(date)
                .build();
    }

    @Data
    public static class CameraZH {
        private String CAM_ID;

        private String CAM_NAME;

        private String LAT_WGS84;

        private String LNG_WGS84;

        public Camera covert2Camera(CameraZH zh) {
            return Camera.builder()
                    .cameraId(zh.getCAM_ID())
                    .cameraName(zh.getCAM_NAME())
                    .longitude(zh.getLNG_WGS84())
                    .latitude(zh.getLAT_WGS84())
                    .build();
        }
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Camera {
        private String cameraId;

        private String cameraName;

        private String latitude;

        private String longitude;

        private String cameraStatus;
        @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd'T'HH:mm:ss")
        private Date updateTime;
    }
}
